#include<bits/stdc++.h>
using namespace std;
int z=0,n,T,m,L,V;
int d[100010],v[100010],a[100010];
vector<int> k[100010];
int p[100010];
bool vis[100010],vvis[100010];
int ans;
void dfs(int num,int w){
	if(w>=ans)return;
	if(num>=z){
		ans=w;
		return ;
	}
	for(int i=1;i<=m;i++){
		if(vvis[i])continue;
		vvis[i]=1;
		int ww=0;
		vector<int> cv;
		for(int j=0;j<k[i].size();j++){
			if(!vis[k[i][j]]){
				vis[k[i][j]]=1;
				cv.push_back(k[i][j]);
				ww++;
			}
		}
		dfs(num+ww,w+1);
		for(int j=0;j<cv.size();j++){
			vis[cv[j]]=0;
		}
		vvis[i]=0;
	}
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>T;
	memset(vis,0,sizeof vis);
	while(T--){
		memset(vvis,0,sizeof vvis);
		z=0;
		cin>>n>>m>>L>>V;
		for(int i=1;i<=n;i++){
			cin>>d[i]>>v[i]>>a[i];
		}
		for(int i=1;i<=m;i++){
			cin>>p[i];
			k[i].clear();
			for(int j=1;j<=n;j++){
				if(p[i]>=d[j]){
					if(sqrt((v[j]*v[j])+(2*a[j]*(p[i]-d[j])))>V){
						k[i].push_back(j);
						if(!vvis[j]){
							vvis[j]=1;
							z++;
						}
					}
					else if(sqrt((v[j]*v[j])+(2*a[j]*(p[i]-d[j])))==V&&V*V!=(v[j]*v[j])+(2*a[j]*(p[i]-d[j]))){
						k[i].push_back(j);
						if(!vvis[j]){
							vvis[j]=1;
							z++;
						}
					}
				}
			}
		}
		ans=0x3f3f3f3f;
		memset(vvis,0,sizeof vvis);
		dfs(0,0);
		cout<<z<<" "<<m-ans<<endl;
	}
	return 0;
}
